import os

from public.public_varliable import curent_time


def write_log(text):
    # 如果打开的文件不存在，会自动创建
    pub_path = os.path.dirname(__file__)  # 查看传入路径的目录名称
    proj_path = os.path.dirname(pub_path)
    file_path = proj_path + '/Logs/' + '2025_02_21.log'
    # r 读
    # w 覆盖写入
    # a 追加
    # 对文件操作,做的操作是需要和模式匹配的，要写就得用w或者a，不能用r
    with open(file=file_path,mode='a',encoding='utf-8') as f:
        f.write(curent_time + "【:】" + text + '\n')

if __name__ == '__main__':
    write_log('566565')
# pub_path = os.path.dirname(__file__)  #查看传入路径的目录名称
# proj_path = os.path.dirname(pub_path)
# file_path = proj_path + '/Logs/' + '2025_02_21.log'